<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">

        <ui:define name="content">
         <p:panel header="Sales Leads" id="salesLeadList" toggleable="true">     
            <h:form prependId="false">
                <h:outputText escape="true" value="#{bundle.ListSalesLeadEntityEmpty}" rendered="#{salesLeadEntityController.searchItems.rowCount == 0}"/>
                <h:panelGroup rendered="#{salesLeadEntityController.searchItems.rowCount > 0}">
                    <p:dataTable value="#{salesLeadEntityController.searchItems}" var="item"
                                 style="table-layout:fixed"
                                 paginator="true" rows="10"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15">
                        <p:column filterBy="#{item.id}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesLeadEntityTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>                      
                        <p:column filterBy="#{item.name}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesLeadEntityTitle_name}"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </p:column>
                        <p:column filterBy="#{item.companyName}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesLeadEntityTitle_companyName}"/>
                            </f:facet>
                            <h:outputText value="#{item.companyName}"/>
                        </p:column>

                        <p:column filterBy="#{item.customerType}">
                            <f:facet name="header">
                                <h:outputText value="Customer Type"/>
                            </f:facet>
                            <h:outputText value="#{item.customerType}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesLeadEntityTitle_isArchived}"/>
                            </f:facet>
                            <h:outputText value= "Archived" rendered="#{item.archived==true}"/>
                            <h:outputText value= "Active" rendered="#{item.archived==false}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>                                        
                            </f:facet>
                            <p:commandButton image="ui-icon ui-icon-search" update="display" oncomplete="salesLeadDialog.show()">
                                <f:setPropertyActionListener value="#{item}"  
                                                             target="#{salesLeadEntityController.salesLead}" /> 
                            </p:commandButton>
                        </p:column>
                        <p:column>  
                            <p:menuButton value="Options">  
                                <p:menuitem value=" Convert" ajax="false" icon="ui-icon ui-icon-arrowrefresh-1-w" 
                                            action="#{salesLeadEntityController.prepareSearchPageConvert}" rendered="#{item.archived==false and loginBacking.convertSalesLead}"/>  
                                <p:menuitem value=" Edit" ajax="false" icon="ui-icon ui-icon-disk" rendered="#{loginBacking.editSalesLead }" 
                                            action="#{salesLeadEntityController.prepareSearchPageEdit}"/>
                                <p:menuitem value=" Delete" ajax="false" rendered="#{item.archived==false and loginBacking.deleteSalesLead}" icon="ui-icon ui-icon-close"
                                            action="#{salesLeadEntityController.searchPageDestroy}"/> 
                                <p:menuitem value=" Activate" ajax="false" rendered="#{item.archived==true and loginBacking.deleteSalesLead}" icon="ui-icon ui-icon-close"
                                            action="#{salesLeadEntityController.searchPageActivate}"/> 
                            </p:menuButton>    
                        </p:column>
                    </p:dataTable>
                    <p:dialog header="Sales Lead Detail" widgetVar="salesLeadDialog" resizable="false"  
                              width="325" showEffect="explode" hideEffect="explode">  

                        <h:panelGrid id="display" columns="2" cellpadding="4">  
                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_companyName}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.companyName}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_jobTitle}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.jobTitle}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_name}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.name}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_firstName}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.firstName}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_lastName}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.lastName}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_title}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.title}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_contact}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.contact}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_id}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.id}"/>

                            <h:outputText value="Customer Type"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.customerType}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_createdAt}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.createdAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_createdBy}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.createdBy.firstName}&nbsp;#{item.createdBy.lastName}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_lastModifiedAt}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.lastModifiedAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_lastModifiedBy}"/>
                            <h:outputText value="#{salesLeadEntityController.salesLead.lastModifiedBy.firstName}"/>

                            <h:outputText value="#{bundle.ListSalesLeadEntityTitle_isArchived}"/>
                            <h:outputText value= "Archived" rendered="#{salesLeadEntityController.salesLead.archived==true}"/>
                            <h:outputText value= "Active" rendered="#{salesLeadEntityController.salesLead.archived==false}"/>

                        </h:panelGrid>  
                    </p:dialog>
                </h:panelGroup>
            </h:form>
         </p:panel>
        </ui:define>
    </ui:composition>

</html>
